import { IsEnum, IsInt, IsOptional, IsString, Min } from 'class-validator';

export enum PageEnum {
  /** 页码 */
  PAGE_NUM = 'pageNum',
  /** 每页数量 */
  PAGE_SIZE = 'pageSize',
  /** 排序字段 */
  SORT_BY = 'sortBy',
  /** 排序规则 */
  SORT_ORDER = 'sortOrder',
}

export enum SortOrderEnum {
  /** 升序 */
  ASC = 'asc',
  /** 倒序 */
  DESC = 'desc',
}

export class PagingQueryDto {
  @IsInt()
  @Min(1)
  pageNum: number;

  @IsInt()
  @Min(1)
  pageSize: number;

  @IsOptional()
  @IsString()
  sortBy?: string;

  @IsEnum(SortOrderEnum)
  @IsOptional()
  sortOrder?: SortOrderEnum;
}
